/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package model.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author dingnangen
 */
@Entity
@Table(name = "message")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Message.findAll", query = "SELECT m FROM Message m"),
    @NamedQuery(name = "Message.findByIdmessage", query = "SELECT m FROM Message m WHERE m.idmessage = :idmessage"),
    @NamedQuery(name = "Message.findByStatus", query = "SELECT m FROM Message m WHERE m.status = :status"),
    @NamedQuery(name = "Message.findByCreatetime", query = "SELECT m FROM Message m WHERE m.createtime = :createtime"),
    @NamedQuery(name = "Message.findByViewtime", query = "SELECT m FROM Message m WHERE m.viewtime = :viewtime"),
    @NamedQuery(name = "Message.findByMsg", query = "SELECT m FROM Message m WHERE m.msg = :msg")})
public class Message implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idmessage")
    private Integer idmessage;
    @Column(name = "status")
    private Integer status;
    @Column(name = "createtime")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createtime;
    @Column(name = "viewtime")
    @Temporal(TemporalType.TIMESTAMP)
    private Date viewtime;
    @Size(max = 1000)
    @Column(name = "msg")
    private String msg;
    @JoinColumn(name = "createuserid", referencedColumnName = "iduser")
    @ManyToOne
    private User createuserid;
    @JoinColumn(name = "createrole", referencedColumnName = "idrole")
    @ManyToOne
    private Role createrole;
    @JoinColumn(name = "recrole", referencedColumnName = "idrole")
    @ManyToOne
    private Role recrole;
    @JoinColumn(name = "recuserid", referencedColumnName = "iduser")
    @ManyToOne
    private User recuserid;

    public Message() {
    }

    public Message(Integer idmessage) {
        this.idmessage = idmessage;
    }

    public Integer getIdmessage() {
        return idmessage;
    }

    public void setIdmessage(Integer idmessage) {
        this.idmessage = idmessage;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public Date getCreatetime() {
        return createtime;
    }

    public void setCreatetime(Date createtime) {
        this.createtime = createtime;
    }

    public Date getViewtime() {
        return viewtime;
    }

    public void setViewtime(Date viewtime) {
        this.viewtime = viewtime;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public User getCreateuserid() {
        return createuserid;
    }

    public void setCreateuserid(User createuserid) {
        this.createuserid = createuserid;
    }

    public Role getCreaterole() {
        return createrole;
    }

    public void setCreaterole(Role createrole) {
        this.createrole = createrole;
    }

    public Role getRecrole() {
        return recrole;
    }

    public void setRecrole(Role recrole) {
        this.recrole = recrole;
    }

    public User getRecuserid() {
        return recuserid;
    }

    public void setRecuserid(User recuserid) {
        this.recuserid = recuserid;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idmessage != null ? idmessage.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Message)) {
            return false;
        }
        Message other = (Message) object;
        if ((this.idmessage == null && other.idmessage != null) || (this.idmessage != null && !this.idmessage.equals(other.idmessage))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.entity.Message[ idmessage=" + idmessage + " ]";
    }

}
